<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>03-饼图制作01</title>
    <!-- 1.引入刚刚下载的 ECharts 文件 -->
    <script src="./echarts/echarts.min.js"></script>
</head>

<body>
    <!-- 2.为 ECharts 准备一个定义了宽高的 DOM -->
    <div id="main" style="width: 600px;height:400px;"></div>
    <script>
        //3.创建echarts 实例并渲染
        // 3.1 基于准备好的dom，初始化echarts实例
        const myChart = echarts.init(document.querySelector('#main'));
        // 3.2指定图表的配置项和数据(设置图标样式)
        const option = {
            title: {
                text: '班级薪资分布',
                left: '20',
            },
            tooltip: {
                trigger: 'item'
            },
            legend: {
                top: '95%',
                left: 'center'
            },
            color: ['#FDA224', '#5097FF', '#3ABCFA', '#34D39A'],
            series: [
                {
                    name: '班级薪资分布',
                    type: 'pie',
                    radius: ['57%', '70%'],
                    avoidLabelOverlap: false,
                    itemStyle: {
                        borderRadius: 90,
                        borderColor: '#fff',
                        borderWidth: 4
                    },
                    label: {
                        show: false,
                        position: 'center'
                    },
                    emphasis: {
                        label: {
                            show: true,
                            fontSize: 40,
                            fontWeight: 'bold'
                        }
                    },
                    labelLine: {
                        show: false
                    },
                    data: [
                        { value: 220, name: '1万以下' },
                        { value: 735, name: '1-1.5万' },
                        { value: 340, name: '1.5万-2万' },
                        { value: 484, name: '2万以上' },
                    ]
                }
            ]
        }
        // 3.3使用刚指定的配置项和数据显示图表。(渲染图表样式)
        myChart.setOption(option);
    </script>
</body>

</html>